<?php
function page_head() {
	if(!session_id()) { session_start(); }
	echo '
	<!DOCTYPE html>
	<html>
	<head>
		<title>Option Pricing</title>
		<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
		<link href="css/main.css" rel="stylesheet" type="text/css" />
		<script language="JavaScript" type="text/javascript" src="js/main.js"></script>
		<script language="JavaScript" type="text/javascript" src="js/functions.js"></script>
		<link href="http://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet" type="text/css">
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
	</head>
	<body>
		<header>
			<a href="index.php" id="title">Option Pricing</a>
			<ul id="navigation-menu">
			';
				if(isset($_SESSION['user_id'])) { echo '<li id="navigation-list" class="mid-navigation-list"><a href="support.php">Inbox <span id="inbox-count">2</span></a></li>'; }
				echo '
				<li id="navigation-list-drop-down">
					Navigation
					<ul>
						<li id="navigation-list-item" class="mid-list-item"><a href="about_us.php" class="drop-down-link"><div class="navigation-list-item-container">About<span class="list-arrow">></span></div></a></li>
						<li id="navigation-list-item" class="mid-list-item"><a href="faq.php" class="drop-down-link"><div class="navigation-list-item-container">FAQ<span class="list-arrow">></span></div></a></li>
					';
					if(isset($_SESSION['user_id'])) {
						echo '
							<li id="navigation-list-item" class="mid-list-item"><a href="viewstocks.php" class="drop-down-link"><div class="navigation-list-item-container">View Stocks<span class="list-arrow">></span></div></a></li>
							<li id="navigation-list-item" class="mid-list-item"><a href="calculator.php" class="drop-down-link"><div class="navigation-list-item-container">Calculator<span class="list-arrow">></span></div></a></li>
							<li id="navigation-list-item"><a href="portfolio.php" class="drop-down-link"><div class="navigation-list-item-container">Option Portfolio<span class="list-arrow">></span></div></a></li>
						';
					}
				echo '
					</ul>
				</li>
				<li id="navigation-list">
					<a href="contact_us.php">Contact Us</a>
				</li>
			</ul>
			<nav>
			';
			if(!isset($_SESSION['user_id'])) {
				echo '
					<form id="login-form" class="header-button" onsubmit="login(); return false">
						<input id="header-bar-form" type="text" id="login-username" name="username" placeholder="Username" /> 
						<input id="header-bar-form" type="password" id="login-password" name="password" placeholder="Password" />
						<input id="header-bar-form-button" type="submit" value="Login" />
					</form><a href="register.php" class="header-link" id="register-button">Register</a>
				';
			} else {
				echo 'Welcome, ' . $_SESSION['username'] . " <a id='logout-button' onclick='logout(); return false;'>Logout</a>";
			}
			echo '
			</nav>
		</header>
		<div id="wrapper">
			';
			if(isset($_SESSION['user_type'])) {
				echo '<ul>
						<li><a href="admin.php">Admin Control Panel</a></li>
						<li><a href="inbox.php">Inbox</a></li>
						<li><a href="user_manager.php">Manage Users</a></li>
					</ul>';
			}
}

function page_foot() {
	echo '
		</div><!--Wrapper Div End-->
	</body>
	</html>
	';
}

function fetch_your_messages() {
	include_once('classes/contactadminfunctions.class.php');
	$contact = new ContactAdminFunctions();
	return $contact->retrieveYourMessages();
}

function fetch_new_messages() {
	include_once('classes/contactadminfunctions.class.php');
	$contact = new Contact();
	return $contact->retrieveNewMessages();
}


function fetch_user_messages() {
	include_once('classes/contactuserfunctions.class.php');
	$contact = new ContactUserFunctions();
	return $contact->retrieveYourMessages();
}
?>